function TreeNode(val) {
    this.val = val;
    this.left = this.right = null;
}

// 递归解法
/*
DFS解法
* */
var maxDepth = function (root) {
    if (root == null) return 0
    if (root != null) {
        let left  =  maxDepth(root.left)
        let right = maxDepth(root.right)
        return left > right ? left + 1: right + 1
    }

};
let root = {
    val : 3,
    left : {
        val:9,
        left:null,
        right: null,
    },
    right: {
        val: 20,
        left: 15,
        right: 7,
    },
}
console.log(maxDepth(root))